#ifndef __DSTH_IOCP_H__
#define __DSTH_IOCP_H__

#include "DSTHType.h"

namespace dsth {
class Timestamp;
class IOCPOperation;
class DSTHIocp {
public:
    DSTHIocp();
    ~DSTHIocp();
    void RegisterHandleOrDie(HANDLE handle);
    Timestamp Run(int time_out);
    void OnCompletion(IOCPOperation* op, DWORD errcode = 0, DWORD bytes_transferred = 0);
    void OnPending(IOCPOperation* op);

private:
    // Can't invoke copy constructor or assignment operator
    DSTHIocp(const DSTHIocp&);
    void operator=(const DSTHIocp&);

    enum {
        kWakeForDispatch = 1,
        kOverlappedContainsResult = 2
    };

    void InitIocp(int concurrency);
    HANDLE iocp_handle_;
};

} // namespace
#endif // __DSTH_IOCP_H__
